﻿@{
    ViewBag.Title = "MessageSetEdit";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@{
    var action = ViewData["action"].ToString();
    string Id = ViewData["Id"].ToString();

    string width = ViewData["width"].ToString();
    if (action == "edit")
    {
        Id = ViewData["Id"].ToString();
    }

} 

<div class="mod_dialog" style="display:block;margin-top:@width;left:0px">
    <form id="frmAccount" class="layui-form" lay-filter="frmAccount">
        <div class="hd">
            <h3>消息设置</h3>
        </div>
        <div class="bd">
            <div class="form clearfix nouse" data-col="0">

                <ul class="clearfix">
                    <li>
                        <label class="label">消息编号：</label>
                        <div class="inptxt">
                            <p></p>
                            <input type="text" class="disabled" name="VARIABLE_CODE" lay-filter="VARIABLE_CODE" required lay-verify="required" autocomplete="off" class="layui-input" disabled="disabled">
                        </div>

                    </li>
                    <li>
                        <label class="label">消息描述：</label>
                        <div class="inptxt">
                            <p></p>
                            <input type="text" class="disabled" name="VARIABLE_NAME" lay-filter="VARIABLE_NAME" required lay-verify="required" autocomplete="off" class="layui-input" disabled="disabled">
                        </div>
                    </li>
                    <li>
                        <label class="label">时长：</label>
                        <div class="inptxt">
                            <p></p>
                            <input type="text" name="VARIABLE_VALUE" lay-filter="VARIABLE_VALUE" required lay-verify="required|number" autocomplete="off" class="layui-input" >
                        </div>

                    </li>
                </ul>
            </div>
            </div>
                <div class="fd">
                    <div class="load_btn">
                        <button class="btn_green_m" id="btnEdit" lay-submit lay-filter="btnEdit">保存</button>
                        <button class="btn_gray_m" id="btnCancel">取消</button>
                    </div>
                </div>
    </form>
</div>
<script type="text/javascript">

    $(function () {
        if ("@action" == "edit") {
            $.ajax({
                url: "/Setting/GetMessageSetById/@Id",
                type: "get",
                dataType: "json",
                success: function (data) {
                    var form = layui.form;
                    form.val("frmAccount", data);
                    form.render(); //刷新select选择框渲染
                }
            });
        }
        var form = layui.form;
        form.render(); //刷新select选择框渲染

        form.on('submit(btnEdit)', function (data) {
           var account = $.extend(data.field, { ID: "@Id" });
            com.ajax({
                url: "/Setting/EditMessageSet", type: "post", dataType: "json", data: account, success: function (data) {
                    parent.$("#infoList").datagrid("load");
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭
                }
            });
            return false;
        });
    })

    $("#btnCancel").click(function () {
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
        return false;
    });

</script>